home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.03 Mar 89 / Forth Source Code / myarray.f < prev    next >
Encoding:
Text File  |  1989-01-16  |  661 b   |  43 lines  |  [TEXT/MPS ]

  1. !!M Inlines.f
  2. !!S makearray
  3.     subroutine makearray (arraysize, myarray)
  4.     implicit none
  5.  
  6.     integer*4 arraysize
  7.     include 'wendigo:mpw:fincludes:memtypes.f'
  8.     
  9.     structure /array/
  10.         integer*4 f(1)
  11.     end structure
  12.     
  13.     structure /Parray/
  14.         pointer /array/ P
  15.     end structure
  16.     
  17.     structure /Harray/
  18.         pointer /Parray/ H
  19.     end structure
  20.  
  21.     record /Harray/ myarray
  22.  
  23.     integer i,j
  24. c
  25. c    sets up new array of length arraysize
  26. c    and initializes it.
  27. c    returns -1 in arraysize when the handle couldn't be created.
  28. c
  29.     j = newHandle(%val(arraysize*4))
  30.     if (j.ne.0) then
  31.         myarray.h = j
  32.     
  33.         do i=1,arraysize
  34.             myarray.h^.p^.f(i) = i
  35.         end do
  36.     
  37.     else
  38.         arraysize = -1
  39.     end if
  40.     
  41.     return
  42.     end
  43.